<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - /home/jkbs/src/zpr/imageeditor/MBI_svn/algorithm/Matrix.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../../../index.html">directory</a> - <a href="index.html">home/jkbs/src/zpr/imageeditor/MBI_svn/algorithm</a> - Matrix.cpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">81</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">85.2 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">69</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : #include &quot;Matrix.hpp&quot;
<span class="lineNum">       2 </span>                : #include &lt;iostream&gt;
<span class="lineNum">       3 </span>                : #include &lt;list&gt;
<span class="lineNum">       4 </span>                : 
<span class="lineNum">       5 </span>                : using namespace std;
<span class="lineNum">       6 </span>                : using namespace boost;
<span class="lineNum">       7 </span>                : //using namespace boost::python;
<span class="lineNum">       8 </span>                : 
<span class="lineNum">       9 </span><span class="lineCov">             11 : void Sequencee::setSequence(string s){</span>
<span class="lineNum">      10 </span><span class="lineCov">             11 :                 sequence_ = s;</span>
<span class="lineNum">      11 </span><span class="lineCov">             11 : }</span>
<span class="lineNum">      12 </span>                : 
<span class="lineNum">      13 </span><span class="lineCov">              3 : string Sequencee::getSequence(){</span>
<span class="lineNum">      14 </span><span class="lineCov">              3 :         if(sequence_.size() == 0)</span>
<span class="lineNum">      15 </span><span class="lineNoCov">              0 :                 throw logic_error(&quot;No sequence available in: Sequencee::getSequence&quot;);</span>
<span class="lineNum">      16 </span>                :         
<span class="lineNum">      17 </span><span class="lineCov">              3 :         return sequence_;</span>
<span class="lineNum">      18 </span>                : }
<span class="lineNum">      19 </span>                : 
<span class="lineNum">      20 </span><span class="lineCov">              7 : int Sequencee::getSequenceSize(){</span>
<span class="lineNum">      21 </span><span class="lineCov">              7 :         return sequence_.size();</span>
<span class="lineNum">      22 </span>                : }
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span><span class="lineCov">            152 : char Sequencee ::getSequenceElement(int i){</span>
<span class="lineNum">      25 </span><span class="lineCov">            152 :         if(i &gt; sequence_.size())</span>
<span class="lineNum">      26 </span><span class="lineNoCov">              0 :                 throw out_of_range(&quot;Sequence out of range in: Sequencee ::getSequenceElement &quot;);</span>
<span class="lineNum">      27 </span>                : 
<span class="lineNum">      28 </span><span class="lineCov">            152 :         return sequence_[i];</span>
<span class="lineNum">      29 </span>                : }
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span><span class="lineNoCov">              0 : void Sequencee::setSequenceElement(char el){</span>
<span class="lineNum">      32 </span><span class="lineNoCov">              0 :         sequence_.push_back(el);</span>
<span class="lineNum">      33 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">      34 </span>                : 
<span class="lineNum">      35 </span><span class="lineCov">              3 : Matrix::Matrix(){</span>
<span class="lineNum">      36 </span><span class="lineCov">              3 :         matrix_ = PMatrixType(new MatrixType());</span>
<span class="lineNum">      37 </span><span class="lineCov">              3 : }</span>
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span><span class="lineCov">              3 : PMatrixType Matrix::getMatrix(){</span>
<span class="lineNum">      40 </span><span class="lineCov">              3 :         if(matrix_-&gt;size() == 0)</span>
<span class="lineNum">      41 </span><span class="lineNoCov">              0 :                 throw logic_error(&quot;No matrix available in: Matrix::getMatrix&quot;);</span>
<span class="lineNum">      42 </span>                : 
<span class="lineNum">      43 </span><span class="lineCov">              3 :         return matrix_;</span>
<span class="lineNum">      44 </span>                : }
<span class="lineNum">      45 </span>                : 
<span class="lineNum">      46 </span><span class="lineCov">              3 : void Matrix::createMatrix(PSequence a, PSequence b, PSimilarity_matrix s){      </span>
<span class="lineNum">      47 </span><span class="lineCov">              3 :         if(a == NULL || b == NULL || s == NULL)</span>
<span class="lineNum">      48 </span><span class="lineNoCov">              0 :                 throw invalid_argument(&quot;Empty shared_ptr in Matrix::createMatrix&quot;);</span>
<span class="lineNum">      49 </span>                :         
<span class="lineNum">      50 </span>                :         //zmienne pomocnicze
<span class="lineNum">      51 </span><span class="lineCov">              3 :         int match = 0;</span>
<span class="lineNum">      52 </span><span class="lineCov">              3 :         int dismatch = 0;</span>
<span class="lineNum">      53 </span><span class="lineCov">              3 :         int d = -1;</span>
<span class="lineNum">      54 </span><span class="lineCov">              3 :         int s1 = a-&gt;getSequenceSize();</span>
<span class="lineNum">      55 </span><span class="lineCov">              3 :         int s2 = b-&gt;getSequenceSize();</span>
<span class="lineNum">      56 </span><span class="lineCov">              3 :         vec_int wiersz(10);</span>
<span class="lineNum">      57 </span>                : 
<span class="lineNum">      58 </span>                :         //inicjalizacja macierzy
<span class="lineNum">      59 </span><span class="lineCov">              3 :         std::list&lt;int&gt; var_mat;</span>
<span class="lineNum">      60 </span><span class="lineCov">              3 :         std::list&lt;int&gt;::iterator it;</span>
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span><span class="lineCov">             16 :         for(int i = 0; i &lt;= s1; ++i){</span>
<span class="lineNum">      63 </span><span class="lineCov">             72 :                 for(int j = 0; j &lt;= s2; ++j){</span>
<span class="lineNum">      64 </span><span class="lineCov">             82 :                         if (i == 0 || j == 0)</span>
<span class="lineNum">      65 </span><span class="lineCov">             23 :                                 wiersz.push_back(0);    </span>
<span class="lineNum">      66 </span>                :                         else {
<span class="lineNum">      67 </span>                : 
<span class="lineNum">      68 </span><span class="lineCov">             36 :                                 if(a-&gt;getSequenceElement(i - 1) == b-&gt;getSequenceElement(j - 1)){</span>
<span class="lineNum">      69 </span><span class="lineCov">             15 :                                         match = s-&gt;getSimilarityMatrixValue(a-&gt;getSequenceElement(i - 1), b-&gt;getSequenceElement(j - 1));</span>
<span class="lineNum">      70 </span><span class="lineCov">             15 :                                         var_mat.push_back((*matrix_)[i - 1][j - 1] + match);</span>
<span class="lineNum">      71 </span>                :                                 }
<span class="lineNum">      72 </span>                :                                 else{
<span class="lineNum">      73 </span><span class="lineCov">             21 :                                         dismatch= s-&gt;getSimilarityMatrixValue(a-&gt;getSequenceElement(i - 1), b-&gt;getSequenceElement(j - 1));</span>
<span class="lineNum">      74 </span><span class="lineCov">             21 :                                         var_mat.push_back((*matrix_)[i - 1][j - 1] + dismatch);</span>
<span class="lineNum">      75 </span>                :                                 }
<span class="lineNum">      76 </span>                :                                 
<span class="lineNum">      77 </span><span class="lineCov">             36 :                                 var_mat.push_back((*matrix_)[i - 1][j] + d);</span>
<span class="lineNum">      78 </span>                : 
<span class="lineNum">      79 </span><span class="lineCov">             36 :                                 var_mat.push_back(wiersz[j - 1] + d);</span>
<span class="lineNum">      80 </span>                :                         
<span class="lineNum">      81 </span><span class="lineCov">             36 :                                 var_mat.sort();</span>
<span class="lineNum">      82 </span><span class="lineCov">             36 :                                 wiersz.push_back(var_mat.back());</span>
<span class="lineNum">      83 </span><span class="lineCov">             36 :                                 var_mat.clear();</span>
<span class="lineNum">      84 </span>                :                         }
<span class="lineNum">      85 </span>                :                 }
<span class="lineNum">      86 </span><span class="lineCov">             13 :                  matrix_-&gt;push_back(wiersz) ;</span>
<span class="lineNum">      87 </span><span class="lineCov">             13 :                  wiersz.clear();</span>
<span class="lineNum">      88 </span>                :                 
<span class="lineNum">      89 </span><span class="lineCov">              3 :         }</span>
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span><span class="lineCov">              3 : }</span>
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span><span class="lineCov">              4 : void Similarity_matrix::createSimilarityMatrix(const int *elements){</span>
<span class="lineNum">      94 </span><span class="lineCov">             20 :         for(int i = 0; i &lt; 4; ++i){</span>
<span class="lineNum">      95 </span><span class="lineCov">             80 :                 for(int j = 0; j &lt; 4; ++j){</span>
<span class="lineNum">      96 </span><span class="lineCov">             64 :                         similarityMatrix_[i][j] = elements[i * 4 + j];</span>
<span class="lineNum">      97 </span>                :                 }
<span class="lineNum">      98 </span>                :         }
<span class="lineNum">      99 </span><span class="lineCov">              4 : }</span>
<span class="lineNum">     100 </span>                : 
<span class="lineNum">     101 </span><span class="lineCov">             39 : int Similarity_matrix::getSimilarityMatrixValue(char a, char b){</span>
<span class="lineNum">     102 </span>                :         int value;
<span class="lineNum">     103 </span>                :         
<span class="lineNum">     104 </span><span class="lineCov">             52 :         if (a=='A' &amp;&amp; b=='A')</span>
<span class="lineNum">     105 </span><span class="lineCov">             13 :                 value = similarityMatrix_[0][0];</span>
<span class="lineNum">     106 </span><span class="lineCov">             33 :         else if ((a=='A' &amp;&amp; b=='G')||(a=='G' &amp;&amp; b=='A'))</span>
<span class="lineNum">     107 </span><span class="lineCov">              7 :                 value = similarityMatrix_[0][1];</span>
<span class="lineNum">     108 </span><span class="lineCov">             30 :         else if ((a=='A' &amp;&amp; b=='C')||(a=='C' &amp;&amp; b=='A'))</span>
<span class="lineNum">     109 </span><span class="lineCov">             11 :                 value = similarityMatrix_[0][2];</span>
<span class="lineNum">     110 </span><span class="lineCov">              8 :         else if ((a=='A' &amp;&amp; b=='T')||(a=='T' &amp;&amp; b=='A'))</span>
<span class="lineNum">     111 </span><span class="lineNoCov">              0 :                 value = similarityMatrix_[0][3];</span>
<span class="lineNum">     112 </span><span class="lineCov">              9 :         else if (a=='G' &amp;&amp; b=='G')</span>
<span class="lineNum">     113 </span><span class="lineCov">              1 :                 value = similarityMatrix_[1][1];</span>
<span class="lineNum">     114 </span><span class="lineCov">             11 :         else if ((a=='G' &amp;&amp; b=='C')||(a=='C' &amp;&amp; b=='G'))</span>
<span class="lineNum">     115 </span><span class="lineCov">              4 :                 value = similarityMatrix_[1][2];</span>
<span class="lineNum">     116 </span><span class="lineCov">              3 :         else if ((a=='G' &amp;&amp; b=='T')||(a=='T' &amp;&amp; b=='G'))</span>
<span class="lineNum">     117 </span><span class="lineNoCov">              0 :                 value = similarityMatrix_[1][3];</span>
<span class="lineNum">     118 </span><span class="lineCov">              5 :         else if (a=='C' &amp;&amp; b=='C')</span>
<span class="lineNum">     119 </span><span class="lineCov">              2 :                 value = similarityMatrix_[2][2];</span>
<span class="lineNum">     120 </span><span class="lineCov">              2 :         else if ((a=='C' &amp;&amp; b=='T')||(a=='T' &amp;&amp; b=='C'))</span>
<span class="lineNum">     121 </span><span class="lineCov">              1 :                 value = similarityMatrix_[2][3];</span>
<span class="lineNum">     122 </span><span class="lineNoCov">              0 :         else if (a=='T' &amp;&amp; b=='T')</span>
<span class="lineNum">     123 </span><span class="lineNoCov">              0 :                 value = similarityMatrix_[3][3];</span>
<span class="lineNum">     124 </span>                :         else{
<span class="lineNum">     125 </span><span class="lineNoCov">              0 :                 throw invalid_argument(&quot;Bad sequence value in: Similarity_matrix::getSimilarityMatrixValue&quot;);</span>
<span class="lineNum">     126 </span>                :         }
<span class="lineNum">     127 </span>                : 
<span class="lineNum">     128 </span><span class="lineCov">             39 :         return value ;</span>
<span class="lineNum">     129 </span><span class="lineCov">              6 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
